// Token操作工具函数
export const getToken = () => {
    return localStorage.getItem('my_oj_login_token');
};

export const setToken = (token) => {
    localStorage.setItem('my_oj_login_token', token);
};

export const removeToken = () => {
    localStorage.removeItem('my_oj_login_token');
};




export const getCodeId = () => {
    const cur = Date.now() / 1000;
    const time = localStorage.getItem('my_oj_code_id_time_t');
    if (cur - Number(time) > 60 * 5) return "";
    return localStorage.getItem('my_oj_code_id');
};

export const setCodeId = (codeid) => {
    const time = Date.now() / 1000;
    localStorage.setItem('my_oj_code_id', codeid);
    localStorage.setItem('my_oj_code_id_time_t', time + '');
};
// 默认导出所有函数
export default {
    getToken,
    setToken, 
    removeToken
};
